<?php

namespace App\Admin\Controllers;

use App\Models\FhBanner;
use App\Models\FhPage;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class FhBannerController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new FhBanner(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('title');
            $grid->column('desc');
            $grid->column('url');
            $grid->column('bgs','背景底图')->image("",100,40);
            $grid->column('img','产品图片')->image("",100,40);
            $grid->column('move','动画图')->image("",100,40);
            $grid->column('sort')->switch();
            $grid->column('created_at');
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new FhBanner(), function (Show $show) {
            $show->field('id');
            $show->field('name');
            $show->field('title');
            $show->field('desc');
            $show->field('url');
            $show->field('img');
            $show->field('sort');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new FhBanner(), function (Form $form) {
            $form->display('id');
            $form->text('title');
            $form->text('desc')->maxlength(60);
            $form->text('url');
            $form->image('bgs','背景底图')->dimensions(['min_width' => 1910, 'max_heigth' => 450])->help("背景底图，分辨率1920*450");
            $form->image('img','产品图片')->dimensions(['max_width' => 650, 'max_heigth' => 650])->help("产品图透明底，分辨率550*450");
            $form->image('move','动画图')->dimensions(['max_width' => 820, 'max_heigth' => 650])->help("动画图透明底，分辨率650*450");
            $form->number('sort')->default(1);
            $form->switch('show')->default(1);
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
